<?php

require_once 'models/client.inc';
require_once 'models/catalog.inc';

/**
 * @author dkrasilnikov@gmail.com
 * @orm.table discount(discntid)
 * @orm.key Id
 *
 */
class TMSDiscount extends TNOrmObject {
	const DT_ABSOLUTE = "abs";
	const DT_PERCENTAGE = "prc";
	
	const AT_CLIENT = "clnt";
	const AT_PRODUCT = "prod";
	const AT_ANY = "any_";
	const AT_BOTH = "both";
	
/**
 * @var int
 * @orm.scalar discntid
 */	
	public $Id;

/**
 * @var bool
 * @orm.scalar active
 */
	public $IsActive;
	
/**
 * @var string
 * @orm.scalar name
 */	
	public $Name;
	
/**
 * @var string
 * @orm.scalar type
 */	
	public $Type;
	
/**
 * @var string
 * @orm.scalar apply_rule
 */	
	public $ApplyRule;
	
/**
 * @var float
 * @orm.scalar amount
 */	
	public $DiscountAmount;
	
/**
 * @var bool
 * @orm.scalar use_discount_points
 */	
	public $UseDiscountPoints;
	
/**
 * @var bool
 * @orm.scalar decrement_discount_points
 */	
	public $DecrementDiscountPoints;
	
/**
 * @var float
 * @orm.scalar discount_points
 */	
	public $DiscountPoints;
	
/**
 * @var string
 * @orm.scalar amount_expression
 */	
	public $AmountExpression;
	
/**
 * @var string
 * @orm.scalar cl_check_expr
 */	
	public $ClientCheckExpression;
	
/**
 * @var string
 * @orm.scalar prod_check_expr
 */	
	public $ProductCheckExpression;
	
/**
 * @var string
 * @orm.scalar inc_point_expr
 */	
	public $PointsIncrementExpression;
	
/**
 * @var string
 * @orm.scalar dec_point_expr
 */
	public $PointsDecrementExpression;	
	
	public function __toString(){
		return (string)$this->Name;
	}
}



/**
 * @author dkrasilnikov@gmail.com
 * @orm.table client_discounts(client,discount)
 * @orm.key Client
 * @orm.key Discount
 * 
 * @property TMSClient $Client {@orm.reference Id(client)}
 * @property TMSDiscount $Discount {@orm.reference Id(discount)}
 */
class TMSClientDiscount extends TNOrmObject {
	protected $_orm_client;
	
	protected $_orm_discount_;
	
	public $Points;
	
	public function __toString(){
		return (string)$this->Discount;
	}
}

/**
 * @author dkrasilnikov@gmail.com
 * @orm.table nomenclature_discount(nomenclature,discount)
 * @orm.key Nomenclature
 * @orm.key Discount
 *
 * @property TMSNomenclature $Nomenclature {@orm.reference Id(nomenclature)}
 * @property TMSDiscount $Discount {@orm.reference Id(discount)}
 */
class TMSNomenclatureDiscount extends TNOrmObject {
	protected $_orm_nomenclature_;
	
	protected $_orm_discount_;
	
	public function __toString(){
		return (string)$this->Discount;
	}	
}

/**
 * @author dkrasilnikov@gmail.com
 * @orm.table article_discount(article,discount)
 * @orm.key Article
 * @orm.key Discount
 *
 * @property TMSArticle $Article {@orm.reference Id(article)}
 * @property TMSDiscount $Discount {@orm.reference Id(discount)}
 */
class TMSArticleDiscount extends TNOrmObject {

	protected $_orm_article_;

	protected $_orm_discount_;

	public function __toString(){
		return (string)$this->Discount;
	}
}